<div id="tb<?php echo $uniqid;?>" style="padding:5px">
    <table cellspacing="0" cellpadding="0">
        <tbody>
        <tr>
            <td><span style="line-height:30px;">注册日期</span>
                <input id="rechargeuserlistStartOn" style="width:152px" type="text" class="easyui-datetimebox"> </input>至
                <input id="rechargeuserlistEndOn" style="width:152px" type="text" class="easyui-datetimebox"> </input>
            </td>
            <td>
                <select id="rechargeuserlistKeywordsType" class="forminput inputstyle textbox-text validatebox-text" style="width:80px">
                    <option value="id">会员ID</option>
                    <option value="nickname">会员昵称</option>
                    <option value="phone">手机号</option>
                </select></td>
            <td><input id="rechargeuserlistKeywords" style="width:120px" type="text" placeholder="输入查询内容"
                                class="easyui-input textbox"></td>
            <td>
                <select id="rechargeuserlistStatus" class="forminput inputstyle textbox-text validatebox-text" style="width:110px" onchange="rechargeuserlistSearch()">
                    <option value="">--全部状态--</option>
                    <option value="normal">正常</option>
                    <option value="frozen">冻结</option>
                    <option value="lock">锁定</option>
                </select></td>
            <td><a href="javascript:void(0);" onclick="rechargeuserlistSearch();" class="l-btn l-btn-small l-btn-plain"><span
                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-sousuo"></i><span
                    class="l-btn-text">查询</span></span></a></td>
            <td><a href="javascript:void(0);" onclick="rechargeuserlistReset();" class="l-btn l-btn-small l-btn-plain"><span
                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-shuaxinrefresh39"></i><span
                    class="l-btn-text">重置</span></span></a></td>
            <td><a href="javascript:void(0);" onclick="rechargeuserlistReload();" class="l-btn l-btn-small l-btn-plain"><span
                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-shuaxin"></i><span
                    class="l-btn-text">重载</span></span></a></td>
        </tr>
        </tbody>
    </table>
</div>
<div class="con"  style="-moz-user-select:none;">
    <table id="rechargeuserlist"></table>
</div>
<div id="rechargeuserlistdlg" class="easyui-dialog" style="width:840px; height:520px;" title="信息框" closed="true"></div>
<script>
    var rechargeuserlistReload = function () {
        $("#rechargeuserlist").datagrid('reload');
    };
    var userRecharge = function (mode, id){
        if(id){
            let title ='充值';
            switch (mode){
                case 'money':
                    title += '余额';
                    break;
                case 'score':
                    title += '积分';
                    break;
                case 'jindou':
                    title += '股权';
                    break;
                case 'hongbao':
                    title += '兑换券';
                    break;
                default:
            }
            $("#rechargeuserlistdlg").dialog({
                title: title,
                closed: false,
                width: 640,
                height: 320,
                cache: false,
                href: '/admin/member/recharge?frompage=accountant&mode=' + mode + '&id=' + id,
                modal: true,
                buttons: [{
                    text: '确定',
                    id: 'memberrechargesubmit',
                    iconCls: 'icon-ok',
                }, {
                    text: '关闭',
                    iconCls: 'icon-no',
                    handler: function () {
                        $("#rechargeuserlistdlg").dialog('close');
                    }
                }]
            });
        }else{
            $.messager.alert('提示', '请先选择要充值的会员！', 'warning');
        }

    };

    var rechargeuserlistReset = function (){
        $('#rechargeuserlistKeywords').val('');
        $('#tb<?php echo $uniqid;?> #rechargeuserlistStartOn').datetimebox('setValue', '');
        $('#tb<?php echo $uniqid;?> #rechargeuserlistEndOn').datetimebox('setValue', '');
        rechargeuserlistSearch();
    };
    var rechargeuserlistSearch = function () {
        var height = $(window).height() - $(".top").height() - 46;
        var width = $(window).width() - $(".leftmenu").width() - 8;
        $("#rechargeuserlist").datagrid({
            title: '会员列表',
            width: width,
            height: height,//高度
            singleSelect: true,//如果为true，则只允许选择一行
            striped: true,//是否显示斑马线效果。
            rownumbers: false,//如果为true，则显示一个行号列。
            pagination: true,//是否显示分页
            pageSize: 10,
            pageList: [10, 15, 20, 25],
            method: 'post',
            sortName: 'id',
            sortOrder: 'desc',
            idField: 'id',
            url: '/admin/member/rechargeuserlist',
            queryParams: {
                keywordsType: $('#rechargeuserlistKeywordsType').val(),
                keywords: $('#rechargeuserlistKeywords').val(),
                start_on: $('#rechargeuserlistStartOn').val(),
                end_on: $('#rechargeuserlistEndOn').val(),
                status: $('#rechargeuserlistStatus').val(),
            },
            fitColumns: true,//真正的自动展开/收缩列的大小，以适应网格的宽度，防止水平滚动。
            nowrap: true,//如果为true，则在同一行中显示数据。设置为true可以提高加载性能。 是否换行
            selectOnCheck: false,
            checkOnSelect: true,
            toolbar: '#tb<?php echo $uniqid;?>',
            columns: [[
                {field: 'id', title: 'ID', width: fixWidth(5)},
                {
                    field: 'avatar', title: '头像', width: fixWidth(5), formatter: function (value, rowData, rowIndex) {
                        return value ? "<img height='50px' src='" + value + "'>" : '';
                    }
                },
                {field: 'nickname', title: '用户', width: fixWidth(10), formatter: function (value, rowData, rowIndex) {
                        return value + (rowData.deleted_at ? '<span style="color: red">(已删除)</span>' : '');
                    }},
                {field: 'parent_rechargeuserlist_id', title: '推荐人', width: fixWidth(10)},
                {field: 'phone', title: '手机号', width: fixWidth(8)},
                {
                    field: 'level_info', title: '身份', width: fixWidth(10), formatter(value, rowData) {
                        return value ? value.name : '普通会员';
                    }
                },
                {field: 'money', title: '余额', width: fixWidth(8), sortable: true},
                {field: 'score', title: '积分', width: fixWidth(8), sortable: true},
                {field: 'quanyi', title: '消费补贴', width: fixWidth(4), sortable: true},
                {field: 'jindou', title: '股权', width: fixWidth(4), sortable: true},
                {field: 'hongbao', title: '兑换券', width: fixWidth(4), sortable: true},
                {
                    field: 'status', title: '状态', align:'center', width: fixWidth(8), formatter: function (value, rowData, rowIndex) {
                        if(rowData.deleted_at){
                            return '<span style="color:red">已删除</span>';
                        }else {
                            switch (value) {
                                case 'normal':
                                    return '正常';
                                case 'frozen':
                                    return '冻结';
                                case 'lock':
                                    return '锁定';
                            }
                        }
                    }
                },
                {field: 'created_at', title: '加入时间', width: fixWidth(10)},
                {
                    field: 'options',
                    title: '操作',
                    align: 'center',
                    width: fixWidth(15),
                    formatter: function (value, rowData, rowIndex) {
                        let buttons = '<div class="table"><span class="l-btn l-btn-small color9 table" onclick="userRecharge(\'money\',\'' + rowData.id + '\')"><span class="l-btn-text">余额充值</span></span>';
                        buttons += '<span class="l-btn l-btn-small color9 table" onclick="userRecharge(\'score\',\'' + rowData.id + '\')"><span class="l-btn-text">积分充值</span></span>';
                        buttons += '<span class="l-btn l-btn-small color9 table" onclick="userRecharge(\'jindou\',\'' + rowData.id + '\')"><span class="l-btn-text">股权充值</span></span>';
                        buttons += '<span class="l-btn l-btn-small color9 table" onclick="userRecharge(\'hongbao\',\'' + rowData.id + '\')"><span class="l-btn-text">兑换券充值</span></span>';
                        return buttons + '</div>';
                    }
                },
            ]],
        });
    };
    onDatagridResize("#rechargeuserlist");
    rechargeuserlistSearch();
</script>
